//package com.cq.shop.member.config;
//
//import feign.RequestInterceptor;
//import feign.RequestTemplate;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.Enumeration;
//
///**
// * @description: TODO
// * @author: mYunYu
// * @date: 2021/8/22 17:09
// * @version: v1.0
// */
//@Configuration
//@Slf4j
//public class FeignConfig {
//
//    @Bean
//    public RequestInterceptor requestInterceptor(){
//        return requestTemplate -> {
//            ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//            HttpServletRequest request = attributes.getRequest();
//            Enumeration<String> headerNames = request.getHeaderNames();
//            if(headerNames != null){
//                while (headerNames.hasMoreElements()){
//                    String name = headerNames.nextElement();
//                    String values = request.getHeader(name);
//                    requestTemplate.header(name, values);
//                }
//            }
//            Enumeration<String> parameterNames = request.getParameterNames();
//            StringBuffer body = new StringBuffer();
//            if(parameterNames != null){
//                while (parameterNames.hasMoreElements()){
//                    String name = parameterNames.nextElement();
//                    String values = request.getParameter(name);
//                    body.append(name).append("=").append(values).append("&");
//                }
//            }
//            if(body.length() != 0){
//                body.deleteCharAt(body.length() - 1);
//                requestTemplate.body(body.toString());
//                log.info("feign interceptor body:{}", body.toString());
//            }
//        };
//    }
//
//}
